<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script src="../js/vue.js" type="text/javascript" charset="utf-8"></script>
	</head>
	<body>
		<div id="root">
			姓：<input type="text" v-model="x"><br>
			名：<input type="text" v-model="m"><br>
			姓名：<span>{{xm}}</span>
		</div>
		<script type="text/javascript">
			const vm = new Vue({
				el: '#root',
				data: {
					x: '张',
					m: '三',
					xm: ''
				},
				watch: {
					x: {
						immediate: true,
						handler(newValue, oldValue) {
							setTimeout(() => {
								this.xm = newValue + this.m
							}, 1000);
						}
					},
					m: {
						immediate: true,
						handler(newValue, oldValue) {
							this.xm = this.x + newValue
						}
					}
				}
			})
		</script>
	</body>
</html>
